package com.czy.owner.ui.userinfo;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.ui.BaseActivity;
import com.czy.owner.utils.PhoneUtils;
import com.czy.owner.widget.MyEditText;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by wangyang on 2017/5/9 0009.
 * 修改用户地址
 */

public class UpdateUserAdressActivity extends BaseActivity{
    @BindView(R.id.et_name_adress)
    MyEditText etNameAdress;
    @BindView(R.id.tv_length_tip)
    TextView tvNameTip;
    private String userInfoAdress;
    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_update_user_name_adress;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {
        tvNameTip.setVisibility(View.GONE);
        getToolbarTitle().setText(R.string.user_detail_adress);
        getSubTitle().setText(R.string.save);
        userInfoAdress = getIntent().getStringExtra("userInfoAdress");
        if (userInfoAdress.equals(getString(R.string.user_detail_adress_hint))) {
            etNameAdress.setHint(getString(R.string.user_detail_adress_hint));
        } else {
            etNameAdress.setText(userInfoAdress);
        }
        etNameAdress.setSelection(etNameAdress.getText().toString().length());

    }

    @Override
    protected void updateViews() {

    }

    //保存
    @OnClick(R.id.toolbar_subtitle)
    public void forgetPassword(View view) {
        if (TextUtils.isEmpty(etNameAdress.getText().toString().trim())) {
            PhoneUtils.ShowToastMessage(UpdateUserAdressActivity.this, "详细地址不能为空");
            return;
        }

        Intent intent = new Intent();
        intent.putExtra("userInfoAdress", etNameAdress.getText().toString().trim());
        setResult(UserInfoActivity.USER_DETAIL_ADRESS, intent);
        finish();
    }
}
